/*
 * Copyright 2016-2036 the original author or authors.
 *
 * COMMERCIAL USE OF THIS SOFTWARE WITHOUT WARRANTY IS NOT ALLOWED.
 * Use is subject to license terms! You can distribute a copy of this software
 * to others for free. This software is a non-profit and open-source project.
 * Any contribution to this project will make it better.
 * All rights reserved! Owned by Stephen Liu.
 *
 */
package com.github.raffle.creation.builder;

/**
 * @author ste7en.liu@gmail.com
 * @since 2016/5/3
 */
public class Nutritions {

    private final int size;
    private final int servings;
    private final int calories;
    private final int fat;
    private final int sodium;
    private final int carbo;

    public static class Builder {
        private int size = 1;
        private int servings;
        private int calories;
        private int fat;
        private int sodium;
        private int carbo;

        //内部类可以直接访问外部类的方法
        public Nutritions build() {
            return new Nutritions(this);
        }
        public Builder size(int size) {
            this.size = size;
            return this;
        }

        public Builder servings(int servings) {
            this.servings = servings;
            return this;
        }
        public Builder calories(int calories) {
            this.calories = calories;
            return this;
        }
        public Builder fat(int fat) {
            this.fat = fat;
            return this;
        }
        public Builder sodium(int sodium) {
            this.sodium = sodium;
            return this;
        }
        public Builder carbo(int carbo) {
            this.carbo = carbo;
            return this;
        }
    }

    private Nutritions(Builder builder) {
        size = builder.size;
        servings = builder.servings;
        calories = builder.calories;
        fat = builder.fat;
        sodium = builder.sodium;
        carbo = builder.carbo;
    }
}
